package com.chenchen.code.btrace.script;

import static com.sun.btrace.BTraceUtils.*;

import com.sun.btrace.BTraceUtils;
import com.sun.btrace.annotations.*;

import java.lang.reflect.Field;

/**
 * @Description:
 * @author chenchen
 * @date 2019/5/17 9:26
 */
@BTrace
public class FieldT {

    @OnMethod(
            clazz = "com.chenchen.code.btrace.target.BtraceTarget3",
            method = "adds",
            location = @Location(Kind.ENTRY)
    )
    public static void lookField(@Self Object self){
        Field field = BTraceUtils.field("com.chenchen.code.btrace.target.BtraceTarget3","length");
        int length = (int) BTraceUtils.get(field,self);
        BTraceUtils.println("length: " + length);
    }
}
